package com.jt.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jt.pojo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.jt.service.ItemService;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/item")
public class ItemController {
	
	@Autowired
	private ItemService itemService;

	@RequestMapping("/query")
	public EasyUITable findItemByPage(Integer page, Integer rows){

		return itemService.findItemByPage(page,rows);
	}

	@RequestMapping("/save")
	public SysResult addItem(Item item, ItemDesc itemDesc){
		itemService.addItem(item,itemDesc);
		return SysResult.success();
	}

	@RequestMapping("/delete")
	public SysResult deleteItem(Long[] ids){
		itemService.deleteItem(ids);
		return SysResult.success();
	}

	@RequestMapping("/update")
	public SysResult updateItem(Item item,ItemDesc itemDesc){
		itemService.updateItem(item,itemDesc);
		return SysResult.success();
	}


	@RequestMapping("/updateStatus/{status}")
	public SysResult reshelf(Long[] ids,@PathVariable("status") Integer status){
		itemService.reshelf(ids,status);
		return SysResult.success();
	}

	@RequestMapping("/query/item/desc/{itemId}")
	public SysResult findItemDescById(@PathVariable Long itemId){

		ItemDesc itemDesc = itemService.findItemDescById(itemId);
		return SysResult.success(itemDesc);
	}

	
}
